<template>
	<view>
		<view class="coupon-list" v-if="coupons.length>0">
		    <view class="item stamp" :class="'stamp0'+(item.status!==1?'6':(item.useRange+1))" v-for="(item,index) in coupons" :key="index">
		        <view class="float-li t1">
		            <view class="coupon-left">
		                <view class="t t1">￥</view>
		                <view class="t t2">{{item.discount}}</view>
		                <view class="t t3">{{item.rangeName}}<br/>满{{item.minimums}}减{{item.discount}}</view>
		                <view class="t t4">券码：{{item.code}}</view>
		            </view>
		        </view>
		        <view class="float-li-rig">
		            <view class="coupon-rig">
		               <view class="t1 t">有效期</view>
		               <view class="t2 t">{{item.startDate}}</view>
		               <view class="t2 t">{{item.endDate}}</view>
		               <view class="t3 t"><text>{{item.statusName}}</text></view>
		            </view>
		        </view>
				<i></i>
		    </view>
		</view>
		<view v-else class="text-center text-gray margin-top-100">没有领取优惠卷哦!</view>
	</view>
</template>

<script>
	import {CouponService} from "@/api/PromotionService.js"
	export default {
		data() {
			return {
				coupons:[]
			}
		},
		onPullDownRefresh() {
			this.loadCoupons();
			uni.stopPullDownRefresh();
		},
		onReady() {
			this.loadCoupons();
		},
		methods: {
			loadCoupons(){
				CouponService.getUserCoupons(0).then(res=>{
					this.coupons=res;
					this.coupons.sort(function(c1,c2){
						return c1.status-c2.status;
					})
				});
			}
		}
	}
</script>
